package lc.q51_100;

import lc.q101_150.ListNode;

public class Q83 {

    public ListNode deleteDuplicates(ListNode head) {
        ListNode cur = head;
        while (cur.next != null) {
            // 当前值跟下一节点值相同，下一节点就跳过
            if (cur.val == cur.next.val) {
                cur.next = cur.next.next;
            } else {
                cur = cur.next;
            }
        }
        return head;
    }

    public static void main(String[] args) {
        ListNode listNode = ListNode.buildByArr(new int[]{1,2,3,3,4,4,5});
        Q83 q82 = new Q83();
        ListNode listNode1 = q82.deleteDuplicates(listNode);
        System.out.println(listNode1);
    }
}
